from django import forms

TOPIC_CHOICES = (
    ('Contact', 'Contact'),
    ('Suggestion', 'Suggestion'),
    ('Technical Problem', 'Technical Problem'),
    ('Bug Report', 'Bug Report'),
)

class GuestBookForm(forms.Form):
    topic = forms.ChoiceField(choices=TOPIC_CHOICES)
    message = forms.CharField(widget=forms.Textarea)
    
    def clean_message(self):
        message = self.cleaned_data.get('message', '')
        num_words = len(message)
        if num_words < 6:
            raise forms.ValidationError("At least 6 words!")
        return message
    
class GuestBookFormForAnonymousUser(forms.Form):
    topic = forms.ChoiceField(choices=TOPIC_CHOICES)
    message = forms.CharField(widget=forms.Textarea)
    email = forms.EmailField()
    
    def clean_message(self):
        message = self.cleaned_data.get('message', '')
        num_words = len(message)
        if num_words < 6:
            raise forms.ValidationError("At least 6 words!")
        return message
